/** * Copyright (c) 2016-2019 人人开源 All rights reserved. */

package com.joinval.modules.sys.controller;

import com.joinval.common.utils.PageUtils;
import com.joinval.common.utils.R;
import com.joinval.common.utils.Result;
import com.joinval.modules.sys.service.SysLogService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 系统日志
 *
 * @author Mark sunlightcs@gmail.com
 */
@RestController
@RequestMapping("/sys/log")
public class SysLogController {
	@Autowired
	private SysLogService sysLogService;

	/**
	 * 列表
	 */
	@ResponseBody
	@GetMapping("/list")
//	@RequiresPermissions("sys:log:list")
	public R list(@RequestParam Map<String, Object> params){
		PageUtils page = sysLogService.queryPage(params);

		return R.ok().put("page", page);
	}

	@ApiOperation(value="日志查询")
	@GetMapping("/logPageList")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "pageNo", value = "分页启始值", required = false, paramType = "query", dataType = "Integer"),
			@ApiImplicitParam(name = "pageSize", value = "分页大小", required = false, paramType = "query", dataType = "Integer"),
			@ApiImplicitParam(name = "sortField", value = "排序字段", required = false, paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "sortOrder", value = "排序规则 asc:正排 desc:倒排", required = false, paramType = "query", dataType = "String")
	})
	public Result logPageList(@RequestParam(value = "pageNo",required = false,defaultValue ="0") Integer pageNo,
								  @RequestParam(value = "pageSize",required = false,defaultValue ="10") Integer pageSize,
								  @RequestParam(value = "sortField",required = false,defaultValue ="create_date") String sortField,
								  @RequestParam(value = "sortOrder",required = false,defaultValue ="desc") String sortOrder
	){
		PageUtils page = sysLogService.logPageList(PageUtils.parsePageInfo(pageNo, pageSize, sortField, sortOrder));
//		return R.ok().put("page", page);
		return Result.ok().data(page);
	}

}
